export function download(data) {
  const filename = decodeURI(data.headers['content-disposition'].replace('attachment;filename=', ''))
  const url = window.URL.createObjectURL(new Blob([data.data]))
  const link = document.createElement('a')
  link.style.display = 'none'
  link.href = url
  link.setAttribute('download', filename)
  document.body.appendChild(link)
  link.click()
  URL.revokeObjectURL(link.href)
  document.body.removeChild(link)
}

export function downloadNotFileName(data, filename) {
  const url = window.URL.createObjectURL(new Blob([data.data]))
  const link = document.createElement('a')
  link.style.display = 'none'
  link.href = url
  link.setAttribute('download', filename)
  document.body.appendChild(link)
  link.click()
  URL.revokeObjectURL(link.href)
  document.body.removeChild(link)
}
